package com.cat.dataStructure03;

/**
 * @author 曲大人的喵
 * @description https://leetcode.cn/problems/equal-row-and-column-pairs/
 * @create 2025/11/12 18:44
 * @since JDK17
 */

public class Solution48 {
    public int equalPairs(int[][] grid) {
        int ans = 0, n = grid.length;
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                int f = 1;
                for (int k = 0; k < n; k++) {
                    if (grid[i][k] != grid[k][j]) {
                        f = 0;
                        break;
                    }
                }
                ans += f;
            }
        }

        return ans;
    }
}
